set=ISO-8859-1">etitle>Chapx r 17. Tracing samba system callselinkcrelsshome" href="index.html" itle="SAMBA Deselop&vs Guide">elinkcrelssup" href="pt04.html" itle="Pdr  IV. Debuggcnl nd"atracing>nelinkcrelssprevious" href="pt04.html" itle="Pdr  IV. Debuggcnl nd"atracing>nelinkcrelssnixt" href="wrndows-debug.html" itle="Chapx r 18. Fiedingauseful informaary. y. w ndows">e/heap> slink="#840084" allnk="#0000FF>msuch4n classnavheaper"ms nble width="100%" stmmury="Navigaary.theaper"ms rr< h ctlspan="3" allgn="cdex r>nChapx r 17. Tracing samba system callsPrevesa> Nextesa> lang="en"msuch4n classtitlepage"msuchmsuchmsh24n classtitle>n>csen m="tracing>nesa>Chapx r 17. Tracing samba system callsnAndrew nspan4n classsuren m>nTridgellamh3msuch4n classaffiliatLDI">espan4n classorgen m>nSamba Team
tnspan>apuchmsptlemsptlemsptlemsuchmsptlemsptlemsp> Tris eiletdescribesthow locdo a system callatrace y.tSamba to workaout whe cits doing wrong. Tris is not forath0tfaine ustheart, but istyou are readcnl lris thgn youcare probublyadesp&vate. Actuallyci sceot asabadcasatrg tre abovecmakes i csound,ajustldon't gxp&ct lre outpux to be sery pretty :-) Ok,Fdow. toabuscness. Onacusttrg big advantages ustunixcsystems is naxttrgy nearly allacomets th a system trace utilltyc naxtallows you to monitortallasystem callsc naxta program is making. Tris is dxtremelycusrngtfortdebuggcnl nd"aalso helps whgn lryinl toaworkaout why somethcnl is slowgrclra.cyoucgxp&ct. Youccan use system tracinl s thout any special ntmpilaary. yptLDIs. Th0tsystem trace utilltycis calledFdifferentt ningscon different systems. On Linuxcsystems its calledFstrace. Un r SunOS 4 its called trace. Un r SVR4 sfylecsystems (includcnl solaris) its called truss. Un r many BSDcsystems its calledFktrace. Th0tfirst thcnl youcshoul"ado is readnlre man pcge forayourFnatrse system callatracer. In"lre discussry. belowtI'll assume its called stracecasastracecis lrg"onlycportabl0tsystem tracer (its availnble for free fortmany unixctypes)cnd"aits also goa some usttrg nicest featuras. Next, lrycusrngtstrace y.tsome si 220tcommnd"s. Fortgxa 220, strace lstnb> ortstrace echo hellotnb>. You'll eotice tne cit produces a4LOT ustoutpux. Itcis showcnl youctre argumenxsFto ev/ry system callathaxttrg program makes ad"ath0 rasult. V/ry llttla happens iuaa program s thout a system callaso you get lots ustoutpux. You'll also find tne cit produces a4lot us spreamble> sfuff showcnl trg loadinl ustsh> Td librari s etc. Ignor tris (unlesscits going wrong!) Fortgxa 220, lrg"onlyclcne lrax reallycmatt&vs i ctn/ strace echo hellotnb> outpux is: n write(1, "hello\n", 6) = 6 all lre restcis justlsettinl upllo runttrg program. Ok,Fnow you're famcliarts th strace. To4use it y.tSamba youcneed to straceclre runnrngtsmbd daemDI. Tre say I "dedtot use i cis loafirst logcntfl enmy Windows PCtto trg Samba scnser,Fthgn use smbstatus to find whichtprocesscID lrax clidex is attachedtto,Fthgn asarootFI do strace -p PIDtnb> to attachtto trattprocess. I normallyc Tdireheath0 st rr outpux fl enlris commnd" toca file eor lat rcp&vusal. For gxa 220, istI'mtuscnl a csh sfylecshell: strace -f -p 3872 >&a 2; strace.outorts th a sh sfylecshell:strace -f -p 3872 > strace.out 2>&a 2;1 Note n/ "-f" yptLDI. Tris is onlycavailnble y.tsome systems,cad" allows youtto trace eot justllre currenttprocess, but any children i forks. Tris is great eor fiedingaprineingaproblemstcaused by lrg sprine commnd"" berng wrong. Once youcare attachedtyouctrenccan do wraxeserai cis on tre4clidex naxtistcausingaproblemstnd" youcwill capxur tall lre system calls naxtsmbd makes. Soahow do youFi t& pret lre results? Generully I search through lrg outpux forastringsctraxtI knowtwill appeartshgn lre problem happens. Fortgxa 220, istI amlhavinl touble wi h permcssry.s y.ta4file I woul"asearch for nat4filesFnamaci ctn/ strace yutpux nd" look at th0tsurroundcnl lines. Anulrgr trihkcis loamatch upleiletdescriptor numbers nd" "follow"twhe chappens tocan op&nleiletuneilai cis closed. Beyod"athis youcwill hasecto4use yourFiuieratrse. To4giv/ youcan idea ustwhe cyoucare lookrngtfortre T isaacpieceauststrace yutpux trax showsctraxtnpdes/nulltn t> is not worl"awritenble,twhich causesaprineingaloafailtw th Samba: n [pid 28268] op&n("pdes/null", O_RDWR) = -1 EACCES (Permcssry.cdenied) [pid 28268] op&n("pdes/null", O_WRONLY) = -1 EACCES (Permcssry.cdenied) Tre processcis lryinl toafirst up&nlnpdes/nulltn t> read-write trencread-only. Both fail. Tris meanslnpdes/nulltn t> hasa incorreheapermcssry.s. Prevesa> Upesa>Nextesa>Pdr  IV. Debuggcnl nd"atracing Home Chapx r 18. Fiedingauseful informaary. y. w ndowses dr